<template>
  <div class="layout-container test-sample-selected">
    <div class="layout-container-table">
      <CommonTable
        :data="state.tableData"
        v-model:page="page"
        :total="total"
        v-loading="loading"
        highlight-current-row
        :showSelection="false"
        :showPagination="false"
      >
        <el-table-column prop="sampleName" label="试验样本名称" />
        <el-table-column prop="dytStyle" label="静态评估结果数据">
          <template #default="scope">
            <el-button
              link
              size="small"
              @click="onStaticEvaluateLook(scope.$index, scope.row)"
              >数据查看</el-button
            >
          </template>
        </el-table-column>
        <el-table-column prop="interType" label="动态评估结果数据">
          <template #default="scope">
            <el-button
              link
              size="small"
              @click="onDynmicEvaluateLook(scope.$index, scope.row)"
              >数据查看</el-button
            >
          </template>
        </el-table-column>
        <el-table-column prop="interScenType" label="多相似度融合结果">
          <template #default="scope">
            <el-button
              link
              size="small"
              @click="onMultiSimilarityFusiLook(scope.$index, scope.row)"
              >数据查看</el-button
            >
          </template>
        </el-table-column>
        <el-table-column prop="foreignElectEquip" label="可视化结果">
          <template #default="scope">
            <el-button
              link
              size="small"
              @click="onVisualResultLook(scope.$index, scope.row)"
              >数据查看</el-button
            >
          </template>
        </el-table-column>
      </CommonTable>
    </div>

    <div class="step-buttons common-buttons">
      <el-button type="primary" @click="onBack">返回</el-button>
      <!-- <el-button type="primary" @click="onStoreEvaluateResults"
        >存储评估结果</el-button
      > -->
    </div>
  </div>
</template>

<script lang="ts" setup>
import { onMounted, reactive, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import CommonTable from "@/components/common-table/index.vue";
import { Page } from "@/components/common-table/type";
import { downloadFile } from "@/utils/tools";

let $router = useRouter();
const state = reactive<any>({
  tableData: [],
});
const loading = ref<boolean>(false);
const page = reactive<Page>({
  current: 1,
  pageSize: 20,
});
const total = ref<number>(0);

onMounted(() => {
  const patchEvaluates = localStorage.getItem("patchEvaluates");
  state.tableData = JSON.parse(patchEvaluates);
});

// 静态评估结果数据-数据查看
const onStaticEvaluateLook = (index: number, row: unknown) => {
  $router.push({
    path: "/similarityEvaluateSystem/lookStaticEvaluate",
    query: { dealSampleId: row?.id },
  });
};

// 动态评估结果数据-数据查看
const onDynmicEvaluateLook = (index: number, row: unknown) => {
  $router.push({
    path: "/similarityEvaluateSystem/lookDynamicEvaluate",
    query: { dealSampleId: row?.id },
  });
};

// 多相似度融合结果-数据查看
const onMultiSimilarityFusiLook = (index: number, row: unknown) => {
  $router.push({
    path: "/similarityEvaluateSystem/lookMultiFusion",
    query: { dealSampleId: row?.id },
  });
};

// 可视化结果-数据查看
const onVisualResultLook = (index: number, row: unknown) => {
  $router.push({
    path: "/similarityEvaluateSystem/resultVisualDisplay",
    query: {
      dealSampleId: row?.id,
      layerType: "look",
      pageType: 'patch'
    },
  });
};

// 上一步
const onBack = () => {
  $router.push({
    path: "/similarityEvaluateSystem/patchEvaluate",
    query: {},
  });
};
</script>

<style lang="scss" scoped>
@import "@/assets/style/buttons";
.test-sample-selected {
  .layout-container-table {
    .el-button--small {
      background: transparent;
      color: rgba(24, 81, 237, 1);
      font-size: 13px;
    }
  }

  .step-buttons {
    display: flex;
    justify-content: center;
    box-shadow: 0px 0px 10px rgba(218, 222, 224, 1);
    padding: 10px 0;
  }
}
</style>
